<!doctype html>
<html lang="en">

  <head>
    <meta charset="UTF-8">
    <title>Document</title>
    <script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
  </head>

  <body>
    <div id="content"></div>
    <script type="text/javascript">
      // fileName > md文件 ；htmlDivId > 需要呈现的Div元素id
      function mdToHtml(fileName,htmlDivId){
        var rawFile = new XMLHttpRequest();
        rawFile.open("GET", fileName, false);
        rawFile.onreadystatechange = function(){
          if(rawFile.readyState === 4){
            if(rawFile.status === 200 || rawFile.status == 0){
              var allText = rawFile.responseText;
              // alert(allText);
              document.getElementById(htmlDivId).innerHTML = marked.parse(allText);
            }
          }
        }
        rawFile.send(null);
      }
      mdToHtml("免费PDF文档在线预览及分享工具.md","content")
      // document.getElementById('content').innerHTML = marked.parse(allText);
    </script>
  </body>

</html>